/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/3/21
 * \* Time: 22:12
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class Demo7 {
    public static void serial(){
        //记录程序执行时间
        long beg = System.currentTimeMillis();
        long a = 0;
        for (long i = 0; i < 10_0000_0000; i++) {
            a++;
        }
        for (long i = 0; i < 10_0000_0000; i++) {
            
        }
        long end = System.currentTimeMillis();
        System.out.println("消耗时间："+ (end - beg) + "ms");
    }
    public static  void concurrency() throws InterruptedException {
        long beg = System.currentTimeMillis();
        Thread t1 = new Thread(()->{
            long a =0;
            for (int i = 0; i < 10_0000_0000; i++) {
                a++;
            }
        });
        t1.start();
        Thread t2 = new Thread(()->{
            long b =0;
            for (int i = 0; i < 10_0000_0000; i++) {

            }
        });
        t2.start();

        t1.join();
        t2.join();
        long end = System.currentTimeMillis();
        System.out.println("消耗时间："+ (end - beg) + "ms");
    }

    public static void main(String[] args) throws InterruptedException {
       // serial();
        concurrency();
    }
}
